import axios from 'axios'
import Qs from 'qs'

const instance = axios.create({
    baseURL : 'http://localhost:2345/',
    timeout : 5000
})

//请求拦截器
instance.interceptors.request.use(config => {
    console.log(config.data );
    config.method == 'post' ? config.data = Qs.stringify({...config.data}) : config.params = ({...config.data})
    return config
},error => {
    console.log(error);
    return Promise.reject(error)
})

//相应拦截器
axios.interceptors.response.use(response=>{
    console.log(response);
    return response
},error => {
    console.log(error);
    return Promise.reject(error)
})

export default instance